//
//  YunDanCenterTabbar.m
//  Rabbit
//
//  Created 阿帕 on 2019/12/18.
//  Copyright © 2019 GCY. All rights reserved.
//

#import "WithdrawalTabBar.h"

#import "WithdrawalRecordViewController.h"

#import "SGPagingView.h"

@interface WithdrawalTabBar ()<SGPageTitleViewDelegate, SGPageContentCollectionViewDelegate>
@property (nonatomic, strong) SGPageTitleView *pageTitleView;
@property (nonatomic, strong) SGPageContentCollectionView *pageContentCollectionView;

@end

@implementation WithdrawalTabBar

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupPageView];
    
    self.navigationItem.title = @"提现记录";
    
    self.view.backgroundColor = BackgroundColor;
}

- (void)setupPageView {
    
    CGFloat statusHeight = CGRectGetHeight([UIApplication sharedApplication].statusBarFrame);
    CGFloat pageTitleViewY = 0;
    if (statusHeight == 20.0) {
        pageTitleViewY = 64;
    } else {
        pageTitleViewY = 88;
    }
    
//    WAIT_AUDIT：待审核，AUDITED：已审核，REJECT：驳回，DEALING:处理中，SUCCESS：成功,FAIL：失败
    NSArray *orderStatusArr = @[@"", @"WAIT_AUDIT", @"AUDITED", @"REJECT", @"DEALING,CONVERSION", @"SUCCESS", @"FAIL"];
    NSArray *orderTitleArr = @[@"全部", @"待审核", @"已审核", @"驳回", @"处理中", @"成功" , @"失败"];
    
    SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
    configure.indicatorStyle = SGIndicatorStyleDynamic;
    configure.titleFont = font(17);
    configure.titleColor = Dark_TextColor;
    configure.titleSelectedColor = Theme_ColorValue;
    configure.indicatorColor = Theme_ColorValue;
    configure.indicatorDynamicWidth = 40;
    configure.indicatorHeight = 3.0f;
    configure.showBottomSeparator = NO;
    configure.titleAdditionalWidth = 35;
    configure.badgeColor = [UIColor redColor];
    
    /// pageTitleView
    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 1, ScreenW, 44) delegate:self titleNames:orderTitleArr configure:configure];
    [self.view addSubview:_pageTitleView];
    
    NSMutableArray *childArr = [[NSMutableArray alloc] init];
    for (int i=0; i<orderTitleArr.count; i++) {
        WithdrawalRecordViewController *wrvc = [[WithdrawalRecordViewController alloc] init];
        wrvc.orderStatus = orderStatusArr[i];
        wrvc.accountType = self.accountType;
        wrvc.dataDic = self.dataDic;
        [childArr addObject:wrvc];
    }
    /// pageContentCollectionView
    CGFloat ContentCollectionViewHeight = self.view.frame.size.height - CGRectGetMaxY(_pageTitleView.frame);
    self.pageContentCollectionView = [[SGPageContentCollectionView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_pageTitleView.frame), ScreenW, ContentCollectionViewHeight) parentVC:self childVCs:childArr];
    _pageContentCollectionView.delegatePageContentCollectionView = self;
    [self.view addSubview:_pageContentCollectionView];
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentCollectionView setPageContentCollectionViewCurrentIndex:selectedIndex];
}

- (void)pageContentCollectionView:(SGPageContentCollectionView *)pageContentCollectionView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    [self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];
}

@end
